jQuery.fn.dataTableExt.oApi.fnPagingInfo = function ( oSettings )
		{
			return {
				"iStart":         oSettings._iDisplayStart,
				"iEnd":           oSettings.fnDisplayEnd(),
				"iLength":        oSettings._iDisplayLength,
				"iTotal":         oSettings.fnRecordsTotal(),
				"iFilteredTotal": oSettings.fnRecordsDisplay(),
				"iPage":          oSettings._iDisplayLength === -1 ?
					0 : Math.ceil( oSettings._iDisplayStart / oSettings._iDisplayLength ),
				"iTotalPages":    oSettings._iDisplayLength === -1 ?
					0 : Math.ceil( oSettings.fnRecordsDisplay() / oSettings._iDisplayLength )
			};
		};

	
	function dataTable(data,path) {
		var oLanguage = data.split(",");

		$("#roleAppdata").dataTable( {
			"oLanguage": {
	            "oPaginate": {
	                          "sFirst": oLanguage[0],// ปุ่มกลับมาหน้าแรก
	                          "sLast": oLanguage[1],//ปุ่มไปหน้าสุดท้าย
	                          "sNext": oLanguage[2], //ปุ่มหน้าถัดไป
	                          "sPrevious": oLanguage[3] // ปุ่ม กลับ
	                        	  },
	             "sLengthMenu": oLanguage[4],  
	             "sZeroRecords": oLanguage[5], 
	             "sInfo": oLanguage[6],
	             "sEmptyTable": oLanguage[7],
	             "sLoadingRecords": oLanguage[8],  
	             "sProcessing": oLanguage[9],
	             "sInfoEmpty": oLanguage[10],
	             "sInfoFiltered": oLanguage[11],  
	             "sSearch": oLanguage[12]
	        },
//			"fnRowCallback" : function(nRow, aData, iDisplayIndex){
//                $("td:first", nRow).html(iDisplayIndex +1);
//               return nRow;
//            },
	        "bProcessing": true,
//	        "bServerSide": true,
//	        "sort": "position",
	        //bStateSave variable you can use to save state on client cookies: set value "true" 
	        "bStateSave": false,
	        //Default: Page display length
	        "iDisplayLength": 10,
	        //We will use below variable to track page number on server side(For more information visit: http://legacy.datatables.net/usage/options#iDisplayStart)
	        "iDisplayStart": 0,
	        "fnDrawCallback": function () {
	            //Get page numer on client. Please note: number start from 0 So
	            //for the first page you will see 0 second page 1 third page 2...
	            //Un-comment below alert to see page number
	        	//alert("Current page number: "+this.fnPagingInfo().iPage);    
	        },         
	        "sAjaxSource": "roleApp/roleAppDataTables",
	        "aoColumns": [
	      		{ "mData": null,"mRender": function ( data, type, full ) {    			
	      			var vaChecked = "";
					if($("#paApplicationId").val()!=""){
						var vaApplIdCheked = $("#paApplicationId").val().split(",");
						for(var i=0; i<vaApplIdCheked.length; i++){
							if(vaApplIdCheked[i] == (full.vaApplicationId)){
								vaChecked = "checked";
								break;
							}
						}

					}	
	      			return "<label class=\"label-checkbox\">"+
									" &nbsp;<input type='checkbox' class='chkChoose'  id='chkChoose'  name='chkChoose' onclick='getDataChecked();' value="+full.vaApplicationId+" "+vaChecked+" >"+
									" <span class=\"custom-checkbox info\"></span>"+
							"</label>";					    				    
	      		},sClass: "center", bSortable: false, sWidth: '10%'  },
				{ "mData": "vaApplicationId",sClass: "center", sWidth: '10%' },
				{ "mData": "vaApplicationName",sClass: "left", sWidth: '35%'  },
				{ "mData": "vaLink",sClass: "left", sWidth: '45%'  },
	        ]} 
		);
		
		$('#chk-all').click(function()	{
			if($(this).is(':checked'))	{
				$('#roleAppdata').find('.chk-row').each(function()	{
					$(this).prop('checked', true);
					$(this).parent().parent().parent().addClass('selected');
				});
			}
			else	{
				$('#roleAppdata').find('.chk-row').each(function()	{
					$(this).prop('checked' , false);
					$(this).parent().parent().parent().removeClass('selected');
				});
			}
		});
	}
	
	function getDataChecked() {
		var vaDataOnChecked = '' ;
		var inputElements = document.getElementsByClassName('chkChoose');
		// get checked data
		for(var i=0; inputElements[i]; ++i){
		      if(inputElements[i].checked){
		    	  vaDataOnChecked += inputElements[i].value+",";
		      }
		}		
		$("#paApplicationId").val(vaDataOnChecked);
	}
	
	$(document).ready(function() {
//		document.getElementById('vaRoleId').readOnly  = false;
		var inputElements = document.getElementsByClassName('chkChoose');
	    $('#checkAll').click(function(event) { 
	        if(this.checked) { 
	            $('.chkChoose').each(function() { 
	                this.checked = true;  
	        		// get checked data
	        		var vaDataOnChecked = '' ;
	        		for(var i=0; inputElements[i]; ++i){
	        		      if(inputElements[i].checked){
	        		    	  vaDataOnChecked += inputElements[i].value+",";
	        		      }
	        		}		
	        		$("#paApplicationId").val(vaDataOnChecked);	                
	            });
	        }else{
	            $('.chkChoose').each(function() {
	                this.checked = false;                     
	            });         
	        }
	    });
	});